package puzzle.projecteuler.p100;

import astudy.util.AdvMath;
import astudy.util.Permutation;

public class Problem041 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int[] c = {1,2,3,4,5,6,7};
		while (c != null) {
			String t = "";
			for (int i = 0; i < c.length; i ++) {
				t += (8-c[i]);
			}
			int p = Integer.valueOf(t);
			if (AdvMath.isPrime(p)) {
				System.out.println(p);
				break;
			}
			c = Permutation.next(c);
		}
	}

}
